import { useSearchParams, history } from "umi";
import { setItem } from "@/utils/localstorage";
import { TOKEN } from "@/constants";
import { useEffect } from "react";
import { message } from "antd";

const PageIn = () => {
  const [search] = useSearchParams();
  const token = search.get("token");
  const targetUrl = search.get("targetUrl");
  useEffect(() => {
    if (!targetUrl || !token) {
      message.info("参数异常，请仔细检查");
      return;
    }
    if (token) {
      setItem(TOKEN, token);
      history.replace(targetUrl || "/home");
    }
  }, []);
  return <div />;
};

export default PageIn;
